summaryrefslogtreecommitdiff
path: root/src/phenotypebinary.h
blob: f312187264d825863202bd7bc9efe29e205af435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef GENETIC_PHENOTYPE_BINARY_H
#define GENETIC_PHENOTYPE_BINARY_H

#include "genetic/phenotype.h"

#include <bu/stream.h>

namespace Genetic
{
	class PhenotypeBinary : public Phenotype
	{
	public:
		PhenotypeBinary( int iSize, bool bRandom=false );
		virtual ~PhenotypeBinary();

		virtual int getSize() { return iSize; }
		virtual Phenotype &randomize();
		virtual void mutate( int iLocation, float fMagnitude );		
		virtual Phenotype *makeEmptyOffspring( int iNewSize=-1 );
		virtual Phenotype &copyFrom( const Phenotype &rSrc, int iStart,
				int iCount, int iDest=-1 );
		virtual Bu::String toString();

		void extractBits( uint32_t &rTarget, int iStart, int iBits );
		void extractBits( uint64_t &rTarget, int iStart, int iBits );

		void write( Bu::Stream &rStream );
		void read( Bu::Stream &rStream );

	private:
		int iSize;
		int iWords;
		uint_fast32_t *aGenes;
	};
};

#endif